<B:UIKD x:Class="WPFExcelReport.TKD02"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                     xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL" 
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT" 
                    xmlns:SP="clr-namespace:WPFExcelReport;assembly=TKDANSP"  
                     xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" 
                     xmlns:B="clr-namespace:WPFExcelReport;assembly=TKDSTAMM" 
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <B:UIKD.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/> 
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>  
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
        <ucd:TextTrimmingConverter x:Key="trim"/>
        <ucd:UPPERGB2312 x:Key="ugb"/>
        <ucd:TRIMGB2312Convert8859P1 x:Key="tgb"/>
    </B:UIKD.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <WrapPanel>
                <Grid Margin="10,0,0,0" IsEnabled="{Binding IsCanNew,ElementName=TV}"  >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" IsEnabled="{Binding IsCanChg,ElementName=TV}"  >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button  Click="EditCommand" Width="24" Height="20">
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" IsEnabled="{Binding IsCanDelete,ElementName=TV}" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" IsEnabled="{Binding IsCanCopy,ElementName=TV}"  >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button    Click="CopyCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/copy.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <B:TSKD02 x:Name="cSKD02" Grid.Column="1" KEY="{Binding KUNDNR,ElementName=TV}" IsEdit="True"/>
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock  Grid.Column="0" Text="{Binding Source={Localization:Translate Word=客户名称:}}"></TextBlock>
                    <ex:TXT72 MaxLength="40" Grid.Column="1" CharacterCasing="Upper"
                              Text="{Binding ART,ElementName=TV,Converter={StaticResource gb2312}}" Width="200" />
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                        </Button.Background>
                    </Button>
                </Grid> 
            </WrapPanel>  
         </StackPanel> 
        <DataGrid  Grid.Row="1"  
                   VerticalAlignment="Top" 
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"  
                   ItemsSource="{Binding Source={StaticResource vwMaster}}"  
                   IsSynchronizedWithCurrentItem="True" 
                   IsReadOnly="True"
                   x:Name="dlgMaster" 
                   RowDetailsVisibilityMode="Visible"
                   GridLinesVisibility="All"
                   MaxHeight="400"
                >
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=KDKUNDNR}" Header="{Binding Source={Localization:Translate Word=编号}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDKUNDNA, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=客户简称}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDKNAME, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=品牌名称}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDNAME1, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=客户名称}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDNAME2, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=客户名称2}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDSTRASSE1, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=客户地址1}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDSTRASSE2, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=客户地址2}}"   Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDLAND}" Header="{Binding Source={Localization:Translate Word=国家}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDMAILADR, Converter={StaticResource tgb}}" Header="{Binding Source={Localization:Translate Word=邮件}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDTEL}" Header="{Binding Source={Localization:Translate Word=电话}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDFAX}" Header="{Binding Source={Localization:Translate Word=传真}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDREGMWST}" Header="{Binding Source={Localization:Translate Word=税}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=KDZENTR}" Header="{Binding Source={Localization:Translate Word=总公司编号}}"  Width="Auto" />
                </DataGrid.Columns>
            </DataGrid  >
        <WrapPanel Grid.Row="2">
            <ex:TCOUNT/> 
        </WrapPanel>
    </Grid>
</B:UIKD>
